﻿using RaytracerLib.MathLib;
using YAXLib;

namespace RaytracerLib.Layers
{
    public class OffsetOperationLayer : UnaryLayer
    {
        [YAXNode]
        public Vector2 Offset { get; set; }

        public OffsetOperationLayer(Vector2 a_offset, Layer a_childLayer)
            : base(a_childLayer)
        {
            Offset = a_offset;
        }

        public override ColorFloat GetColor(Vector2 a_uv, Intersection a_intersection)
        {
            return ChildLayer.GetColor(a_uv + Offset, a_intersection);
        }

        public override double GetValue(Vector2 a_uv, Intersection a_intersection)
        {
            return ChildLayer.GetValue(a_uv + Offset, a_intersection);
        }

        public override Tangents GetTangents(Vector2 a_uv, Vector2 a_tx, Vector2 a_ty,
            Intersection a_intersection)
        {
            return ChildLayer.GetTangents(a_uv + Offset, a_tx, a_ty, a_intersection);
        }
    }
}